<?php

namespace app\common\model;

use app\common\model\user\Artwork;
use think\Model;

class OrderItem extends Model
{
    protected $name = 'order_item';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    const DATA_TYPE_PRODUCT = 'product'; // 商品
    const DATA_TYPE_PACKAGED = 'packaged'; // 套餐
    const DATA_TYPE_ARTWORK = 'artwork'; // 作品

    public function itemdata()
    {
        return $this->morphTo('data', [
            OrderItem::DATA_TYPE_PRODUCT  => Product::class,
            OrderItem::DATA_TYPE_PACKAGED => Packaged::class,
            OrderItem::DATA_TYPE_ARTWORK  => Artwork::class,
        ]);
    }

}